/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "document")
@NamedQueries({
    @NamedQuery(name = "Document.findAll", query = "SELECT d FROM Document d"),
    @NamedQuery(name = "Document.findByDocumentId", query = "SELECT d FROM Document d WHERE d.documentId = :documentId"),
    @NamedQuery(name = "Document.findByDocumentDate", query = "SELECT d FROM Document d WHERE d.documentDate = :documentDate"),
    @NamedQuery(name = "Document.findByDocumentPower", query = "SELECT d FROM Document d WHERE d.documentPower = :documentPower"),
    @NamedQuery(name = "Document.findByDocumentPath", query = "SELECT d FROM Document d WHERE d.documentPath = :documentPath"),
    @NamedQuery(name = "Document.findByDocumentName", query = "SELECT d FROM Document d WHERE d.documentName = :documentName")})
public class Document implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "document_id")
    private Integer documentId;
    @Basic(optional = false)
    @Column(name = "document_date")
    @Temporal(TemporalType.DATE)
    private Date documentDate;
    @Basic(optional = false)
    @Column(name = "document_power")
    private int documentPower;
    @Basic(optional = false)
    @Column(name = "document_path")
    private String documentPath;
    @Basic(optional = false)
    @Column(name = "document_name")
    private String documentName;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;
    @JoinColumn(name = "dc_id", referencedColumnName = "dc_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private DocumentCategory documentCategory;

    public Document() {
    }

    public Document(Integer documentId) {
        this.documentId = documentId;
    }

    public Document(Integer documentId, Date documentDate, int documentPower, String documentPath, String documentName) {
        this.documentId = documentId;
        this.documentDate = documentDate;
        this.documentPower = documentPower;
        this.documentPath = documentPath;
        this.documentName = documentName;
    }

    public Integer getDocumentId() {
        return documentId;
    }

    public void setDocumentId(Integer documentId) {
        this.documentId = documentId;
    }

    public Date getDocumentDate() {
        return documentDate;
    }

    public void setDocumentDate(Date documentDate) {
        this.documentDate = documentDate;
    }

    public int getDocumentPower() {
        return documentPower;
    }

    public void setDocumentPower(int documentPower) {
        this.documentPower = documentPower;
    }

    public String getDocumentPath() {
        return documentPath;
    }

    public void setDocumentPath(String documentPath) {
        this.documentPath = documentPath;
    }

    public String getDocumentName() {
        return documentName;
    }

    public void setDocumentName(String documentName) {
        this.documentName = documentName;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public DocumentCategory getDocumentCategory() {
        return documentCategory;
    }

    public void setDocumentCategory(DocumentCategory documentCategory) {
        this.documentCategory = documentCategory;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (documentId != null ? documentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Document)) {
            return false;
        }
        Document other = (Document) object;
        if ((this.documentId == null && other.documentId != null) || (this.documentId != null && !this.documentId.equals(other.documentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Document[documentId=" + documentId + "]";
    }

}
